<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>

<form:form commandName="model" cssClass="validate"
	action="configuration/category/property/save">
	<form:hidden path="id" />
	<table class=" form-table">
		<tbody>
			<tr>
				<td class="td1">名称：</td>
				<td class="td2"><form:input path="name" cssClass="required" />
				</td>
			</tr>
			<tr>
				<td class="td1">所属分类：</td>
				<td class="td2"><form:hidden path="confCategoryId" /> <isperp:treeSelector
						id="categorySelector" url="configuration/category/getTree"
						valueControlId="confCategoryId" displayValue="${categoryName}"
						displayValueCssClass="required"></isperp:treeSelector>
				</td>
			</tr>
			<tr>
				<td class="td1">类型：</td>
				<td class="td2"><form:select path="dataType">
						<form:option value="string">字符串</form:option>
						<form:option value="number">数字</form:option>
						<form:option value="date">日期</form:option>
						<form:option value="select">自定义下拉选择</form:option>
						<form:option value="textarea">文本框</form:option>
					</form:select></td>
			</tr>
			<tr id="trDatasource" style="display:none">
				<td class="td1">数据源(请用"|"分割)：</td>
				<td class="td2" colspan="3"><form:textarea path="items" />
				</td>
			</tr>
			<tr>
				<td class="td1">默认值：</td>
				<td class="td2"><form:input path="defaultValue" /></td>
			</tr>
			<tr id="trRegex">
				<td class="td1">验证正则式：</td>
				<td class="td2"><form:input path="regex" /></td>
			</tr>
			<tr>
				<td class="td1">必填项：</td>
				<td class="td2"><form:checkbox path="notnull" />
				</td>
			</tr>
			<tr>
			<tr>
				<td class="td1">排序：</td>
				<td class="td2"><form:input path="orderNum" cssClass="number" />
				</td>
			</tr>
		</tbody>
	</table>

</form:form>
<isperp:buttonList>
	<button class="submit" onclick="isperp.submitForm();return false;">
		<span class="icon icon-save"></span>提交
	</button>
</isperp:buttonList>

<script type="text/javascript">
	function dataTypeChange() {
		var val = $("#dataType").val();
		if (val == "select") {
			$("#trDatasource").show();
		} else {
			$("#trDatasource").hide();
		}
		if (val != "string") {
			$("#trRegex").hide();
		} else {
			$("#trRegex").show();
		}
	}

	dataTypeChange();
	$("#dataType").change(function() {
		dataTypeChange();

	});
</script>
